﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>

    <title>添加权限</title>
    <script src="~/Scripts/jquery-1.8.2.min.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script src="~/Scripts/MyAjaxForm.js"></script>
    <script src="~/Scripts/jquery.easyui.min.js"></script>

    <script type="text/javascript">

        $(function () {
            bindActionTypeEnumChange();
            bindFileUpClick();
        });
        //文件上传
        function bindFileUpClick()
        {
            $("#btnFileUp").click(function () {
                console.log('001'+'fileup start');
                if ($("#fileUp").val()=="")
                {
                    $.messager.alert("提示", "请选择上传文件", "error");
                    return;
                }
                console.log('002' + 'fileup start');
                //开始进行异步上传
                $("#addRoleForm").ajaxSubmit({
                    success:function(data)
                    {
                        console.log(data);
                    },
                    url: "/ActionInfo/FileUpLoad",
                    type: "post",
                    dataType:"text"
                });
                console.log('003' + 'fileup start');

            });
        }
        //给权限类别绑定change事件
        function bindActionTypeEnumChange()
        {
            
            $("#ActionTypeEnumChange").click(function () {
                console.log(($(this).val()));
                if ($(this).val()=="1")
                {
                    $("#actionIconTr").fadeIn("show");
                }
                else
                {
                    $("#actionIconTr").fadeOut("show");
                }

            })
        }

        function subForm() {
            $("#addRoleForm").submit();
        }
        function afterAdd(data) {
            //调用父窗体中的方法
            window.parent.afterAdd(data);
        }

    </script>

</head>
<body>




    @*@using (Ajax.BeginForm("AddRoleInfo", "RoleInfo", new { },
        new AjaxOptions() { HttpMethod = "post", OnSuccess = "afterAdd" },
        new { id = "addRoleForm" }))*@

    @using (Ajax.BeginForm("AddRoleInfo1", "RoleInfo", new { },
        new AjaxOptions() { HttpMethod = "post", OnSuccess = "afterAdd" },
        new { id = "addRoleForm" }))
    {
        <table>
            <tr><td>权限名称</td><td><input type="text" name="ActionInfoName" /></td></tr>
            <tr><td>URL</td><td><input type="text" name="URL" /></td></tr>
            <tr>
                <td>HttpMethod</td>
                <td>
                    <select name="HttpMethod">
                        <option value="Get">GET</option>
                        <option value="POST">POST</option>
                    </select>
               </td>
            </tr>
            <tr>
                <td>权限类型</td>
                <td>
                    <select name="ActionTypeEnum" id="ActionTypeEnumChange">
                        <option value="0">普通权限</option>
                        <option value="1">菜单权限</option>
                    </select>
                </td>
            </tr>
            <tr style="display:none" id="actionIconTr">                
                <td> 菜单图标 </td>
                <td>
                   <input type="file" name="fileIconUp" id="fileUp" />
                   <input type="button" value="上传图片" id="btnFileUp"/>

                    <div id="showImg"></div>
                </td>
            </tr>
            <tr><td>备注</td><td><input type="text" name="Remark" /></td></tr>
            <tr><td>排序</td><td><input type="text" name="Sort" /></td></tr>
        </table>
        //@Html.AntiForgeryToken()
        @*@Html.ValidationSummary(true)

            <fieldset>
                <legend>RoleInfo</legend>
                <div class="editor-label">
                    @Html.LabelFor(model => model.RoleName)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.RoleName)
                    @Html.ValidationMessageFor(model => model.RoleName)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.Remark)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.Remark)
                    @Html.ValidationMessageFor(model => model.Remark)
                </div>



                <div class="editor-label">
                    @Html.LabelFor(model => model.Sort)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.Sort)
                    @Html.ValidationMessageFor(model => model.Sort)
                </div>
            </fieldset>*@
    }


</body>
</html>


